const sending = require("../mudles/sending");

module.exports = {
  path: "/send",
  method: "post",
  async handle(ctx, next) {
    const cookie = ctx.cookies.get("loginStauts");
    console.log(cookie);
    if (!cookie) {
      ctx.body = {
        code: 2005,
        data: null,
        messsage: "no login"
      };
      return
    }
    const req = ctx.request.body;
    const result = await sending(req);
    console.log(result);
    if (result && result.messageId) {
      ctx.body = {
        code: 2000,
        data: null,
        messsage: "SUCCESS"
      };
    } else {
      ctx.body = {
        code: 2001,
        data: null,
        messsage: "SUCCESS"
      };
    }
  }
};
